// 状态管理
import { createSlice } from '@reduxjs/toolkit'

const initialState = {
    collapsed: false,
    // 读取 用户最后使用左侧栏的状态保存在本地（收/缩）
    collapsed: localStorage.getItem('collapsed') === 'true'
} 
export const appSlice = createSlice({
    name: 'app',
    initialState, 
    reducers: {
        changeCollapsed (state) {
             state.collapsed = !state.collapsed
            }
}
})
export const { changeCollapsed } = appSlice.actions
export default appSlice.reducer